package com.travelranking.converter;

import java.util.ArrayList;
import java.util.List;

import com.travelranking.entity.TravelEntity;
import com.travelranking.pojo.Travel;

public class TravelConverter {

	public static TravelEntity toEntity(Travel pojo) {
		TravelEntity entity = new TravelEntity();
		entity.setId(pojo.getId());
		entity.setOpinion(pojo.getOpinion());
		entity.setCity(CityConverter.toEntity(pojo.getCity()));
		entity.setRank(pojo.getRank());
		return entity;
	}

	public static Travel toPojo(TravelEntity entity) {
		Travel pojo = new Travel();
		pojo.setId(entity.getId());
		pojo.setOpinion(entity.getOpinion());
		pojo.setCity(CityConverter.toPojo(entity.getCity()));
		pojo.setRank(entity.getRank());
		return pojo;
	}

	public static List<Travel> toPojoList(List<TravelEntity> entity) {
		List<Travel> result = new ArrayList<Travel>();
		System.out.println("lista de entities: "+entity);
		if (entity != null) {
			for (TravelEntity e : entity) {
				result.add(toPojo(e));
			}
		}
		return result;
	}

}
